
<%--
 *  File:    OrgAnalyseReportPop.jsp
 *  @Author: DC
 *  Date:    2011/09/13
 *
 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%
  //init param
  String strTableName = "v_zmylagreement";
  String strModuleName = "CRM";
  String privilegeCode = "R10240";
  String contextPath = request.getContextPath();

%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%@ include file="/rpt/ReportURL.inc"%>
<iframe name="reloadHandler" style="display:none"></iframe>

<html>
<head>
<title>VisitProcessSummary</title>
<PageFlow:CheckPageFlow pageName="p_orgreportsummary"/>
<%
HashMap userinfo = (HashMap)session.getAttribute("userinfo");
java.util.Calendar cal = java.util.Calendar.getInstance();
String flag = (String)request.getParameter("flag");
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript"
	src="<%=contextPath%>/js/SummaryDivision.js"></script>


<%@ include file="/inc/SummaryDivision.inc" %>

<script language="JavaScript">


function clickRow(id)
{
  document.frm.oriposdataid.value = id;

  ///document.frm.status.value = status;
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(frm,actionvalue,orderbyname);
  editform.action = "OrgAnalyseReportPop.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}

function page_popwindow1(){
  	if(popwindow!=null)
    	popwindow.close();
  	var strurl="<%=contextPath%>/phap/phap.datp/masterdata/kdm/ProductSelect.jsp?<%= OvalTools.randomURL()%>&languagecode=<%=strLanguageCode%>&clear=Y&category=4"; 
  	var strStatus= "height=500,width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
 	popwindow=window.open(strurl, "newwindow",strStatus);
 	
}

function page_setproduct(id,umcode,prodcode,prodname){
	
	document.frm.prdn.value=prodname;
	document.frm.prodid.value=id;

}

function exportExcel()
{
	var begindate = document.frm.startyears.value+"-"+document.frm.startmonths.value;//日期
	var prodid = document.frm.prodid.value;
	var prdn = document.frm.prdn.value;
	var stdareatype=document.frm.stdareatype.value;
	var strareaname=document.frm.strareaname.value;
	var strareaid=document.frm.areaids.value;
	
	 window.open("<%= reportURL %>/servlet/ExcecuteReport/organizationanalysepop.sox?__format=xlsx&__folder=/ovalreport&startdate="+begindate+"&prodid="+prodid+"&areaids="+strareaid);
}



function popBusinessarea_moulty(){
	if(popwindow!=null) popwindow.close();
	
    //url = '<%=contextPath %>/zyl/masterdata/map/SelectAreaTree.jsp?<%= OvalTools.randomURL() %>';
    url = '<%=contextPath %>/phap/phap.datp/masterdata/cm/dataclean/ZylStdareaSelect.jsp?<%= OvalTools.randomURL() %>';
    attribute = 'height=600, width=900,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';
	popwindow = window.open(url,'newwindow', attribute);
}
function setAreas(areaids,areanames,areacodes){

	document.frm.areaids.value=areaids;
	document.frm.strareaname.value=areanames;
	document.frm.stdareatype.value=areacodes;
}

</script>
</head>
<body style="overflow: auto;">

<form name="frm" method="post" action="../../Dispatcher">
<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
      <input type="hidden" name="pagename" value="p_orgreportsummary">
      <input type="hidden" name="actionname">  
      <input type="hidden" name="categorycode" /> 
      <input type="hidden" name="mark" value="1" /> 
	<custom:hidden property="userid" name="userinfo" scope="session"/>
	<custom:hidden property="deptcode" name="userinfo" scope="session"/> 
	<custom:hidden property="globalpccode"/>
      
<!-- 条件查询 -->
	<tr>
		<table width="70%" border="0" cellspacing="0">
		        <tr>
		        <%
                    //String year = cal.get(Calendar.YEAR)+"";     
					//String month = cal.get(Calendar.MONTH)+"";
					String year = cal.get(Calendar.YEAR)+"";     
					String month = cal.get(Calendar.MONTH)+"";
					if(cal.get(Calendar.MONTH) == 0){
						month = "12";
						year = (cal.get(Calendar.YEAR)-1)+"";
					}					
		        if("first".equals(flag)){ 
		        %>
		        	<td class="title_center">
					<div align="right">
						<%=label.getLabelName("L_StartYear")+label.getLabelName("L_Colon")%>
					</div>
					</td>
					<td class="title_center">
						<div align="left">
						<!-- 
							<custom:selectdic property="startyears" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1" />
						 -->
						 <custom:selectdic property="startyears" dictType="Years"  value="<%=year %>" defaultValueCost="" label="L_Year1" />
						</div>
					</td>
			
					<td class="title_center">
						<div align="right">
							<%=label.getLabelName("L_BeginMonth")+label.getLabelName("L_Colon")%>
						</div>
					</td>
				<td class="title_center">
						<div align="left">
						<!-- 
							<custom:selectdic property="startmonths" dictType="Months" command="notnull" value="<%=month %>" label="L_Month" />
						 -->
							<custom:selectdic property="startmonths" dictType="Months" value="<%=month %>"  defaultValueCost="" label="L_Month" />
						</div>
					</td>
		        <!-- 
		        <td colspan="2">
		        
						<%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %>
						<custom:selectdic property="startyears" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1" />
						<custom:selectdic property="startmonths" dictType="Months" command="notnull" value="<%=month %>" label="L_Month" /> - <custom:selectdic property="endyears" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1" />
						<custom:selectdic property="endmonths" dictType="Months" command="notnull" value="<%=month %>" label="L_Month" />

					</td>
		         -->
			        <td class="title_center">
						<div align="right">
							<%=label.getLabelName("L_Provicetdr")+label.getLabelName("L_Colon")%>
						</div>
					</td>
					<td>
						<custom:hidden property="stdareatype" />
			           	<custom:text property="strareaname"/>
			           	<custom:hidden property="areaids" />
			           	<a onclick="popBusinessarea_moulty();"><custom:button type="3" value="*"/></a>
					</td>			   
			   
			   		<td class="title_center">
						<div align="left">
							<%=label.getLabelName("L_Product")	+ label.getLabelName("L_Colon")%>
					    </div>
		            </td>
		            <td>
						<custom:text  property="prdn" size="30" readonly="true"/>&nbsp;<a onclick="page_popwindow1();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
		        		<custom:hidden property="prodid"/>
						<a href="javascript:page_summary('search')"><img src="<%=contextPath%>/images/<%= strLanguageCode %>/go.gif" border="0" ></a>		        		
                    </td>	

		        	<%}else{ %>
		        	<td class="title_center">
					<div align="right">
						<%=label.getLabelName("L_StartYear")+label.getLabelName("L_Colon")%>
					</div>
					</td>
					<td class="title_center">
						<div align="left">
						<!-- 
							<custom:selectdic property="startyears" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1" />
						 -->
						 <custom:selectdic property="startyears" dictType="Years"  defaultValueCost="" label="L_Year1" />
						</div>
					</td>
			
					<td class="title_center">
						<div align="right">
							<%=label.getLabelName("L_BeginMonth")+label.getLabelName("L_Colon")%>
						</div>
					</td>
				<td class="title_center">
						<div align="left">
						<!-- 
							<custom:selectdic property="startmonths" dictType="Months" command="notnull" value="<%=month %>" label="L_Month" />
						 -->
							<custom:selectdic property="startmonths" dictType="Months"   defaultValueCost="" label="L_Month" />
						</div>
					</td>
		        	<!-- 
		        	<td colspan="2">

						<%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %>
						<custom:selectdic property="startyears" dictType="Years" command="notnull"  label="L_Year1" />
						<custom:selectdic property="startmonths" dictType="Months" command="notnull"  label="L_Month" /> - <custom:selectdic property="endyears" dictType="Years" command="notnull"  label="L_Year1" />
						<custom:selectdic property="endmonths" dictType="Months" command="notnull"  label="L_Month" />

					</td>
		        	 -->
		        	<td class="title_center">
						<div align="right">
							<%=label.getLabelName("L_Provicetdr")+label.getLabelName("L_Colon")%>
						</div>
					</td>
					<td>
						<custom:hidden property="stdareatype" />
			           	<custom:text property="strareaname"/>
			           	<custom:hidden property="areaids" />
			           	<a onclick="popBusinessarea_moulty();"><custom:button type="3" value="*"/></a>
					</td>			   
			   
			   		<td class="title_center">
						<div align="left">
							<%=label.getLabelName("L_Product")	+ label.getLabelName("L_Colon")%>
					    </div>
		            </td>
		            <td>
						<custom:text  property="prdn" size="30" readonly="true"/>&nbsp;<a onclick="page_popwindow1();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
		        		<custom:hidden property="prodid"/>
		        		<a href="javascript:page_summary('search')"><img src="<%=contextPath%>/images/<%= strLanguageCode %>/go.gif" border="0" ></a>
                    </td>	

		        	<%} %>	
          	</tr>
		</table>
	</tr>      
      
 <%-- 
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0">
        <tr> 
          <td class="summary_top" colspan="3" ></td>
        </tr>
        <tr>
          <td>    
            <table border="0" cellspacing="0">    
            <%@ include file="/inc/SummarySearch.inc" %>  
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
 --%>  
<tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0">
        <tr> 
          <td class="summary_top" colspan="3" ></td>
        </tr>
        <tr>
          <td> &nbsp;   
          </td>
        </tr>
      </table>
    </td>
  </tr>   
    
  <tr> 
    <td> 
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
          <tr class="deepblue-left">
			  <td width="2%" class="title_center">&nbsp;</td>
              <td width="2%" class="title_center"><a href="javascript:page_summary('orderby','year')"><%= label.getLabelName("L_YearF")%></a></td>			  
              <td width="2%" class="title_center"><a href="javascript:page_summary('orderby','month')"><%= label.getLabelName("L_Month")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','area1name')"><%= label.getLabelName("L_RegionName")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','productcode')"><%= label.getLabelName("L_ProdCode") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','productname')"><%= label.getLabelName("L_ProductName") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','listprice')"><%= label.getLabelName("L_UnitPrice") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','initialqty')"><%= label.getLabelName("L_LastInv") + label.getLabelName("L_Case") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','purchaseqty')"><%= label.getLabelName("L_ThisInv") + label.getLabelName("L_Case") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','salesqty')"><%= label.getLabelName("L_ThisSales") + label.getLabelName("L_Case") %></a></td>         
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','allqty')"><%= label.getLabelName("L_MonthStockHJ")+ label.getLabelName("L_Case") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','theoryqty')"><%= label.getLabelName("L_MonthStockJS")+ label.getLabelName("L_Case")%></a></td>              
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','differenceqty')"><%= label.getLabelName("L_MonthStockDIF") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','initialamount')"><%= label.getLabelName("L_LastInv") + label.getLabelName("L_Thousand")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','purchaseamount')"><%= label.getLabelName("L_ThisInv") + label.getLabelName("L_Thousand")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','salesamount')"><%= label.getLabelName("L_ThisSales") + label.getLabelName("L_Thousand")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','allamount')"><%= label.getLabelName("L_MonthStockHJ")+ label.getLabelName("L_Thousand") %></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','theoryamount')"><%= label.getLabelName("L_MonthStockJS")+ label.getLabelName("L_Thousand")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','differenceamount')"><%= label.getLabelName("L_MonthStockDIF")+ label.getLabelName("L_Thousand")%></a></td>
              <td width="4%" class="title_center"><a href="javascript:page_summary('orderby','cnsales')"><%= label.getLabelName("L_SalesDiversity")%></a></td>
		</tr>
          <%
             Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
             if(totalsummary == null)
             {
            	 totalsummary = new Vector();
             }
             String strClassType = new String("");   
             Integer nDefaultId = null;             
             Integer nDefaultStatus = null;
             Integer nDefaultVersion = new Integer(-1);
             int i=0;
             String strChecked = "";
             boolean bHasChecked = false;
          %>   
          <logic:iterate id="agreementsummary" collection="<%= totalsummary %>">
          <%
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            if(!bHasChecked)
            {
              nDefaultId = (Integer)((HashMap)pageContext.getAttribute("agreementsummary")).get("oriposdataid");
              bHasChecked = true;
              strChecked = "Checked";
            }
            else
            {
              strChecked = "";
            }
            i++;
          %>            
          <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="radiotrue('oriposdataid<%=JspHelper.filterNull( i )%>');
			    javascript:clickRow('<oval:write name="agreementsummary" property="oriposdataid" />');"
          class="<%=JspHelper.filterNull( strClassType )%>"> 
            <td> 
              <input <%=JspHelper.filterNull( strChecked )%> id="oriposdataid<%=JspHelper.filterNull( i )%>" type="radio" name="order" value="<oval:write name="Summaryitem" property="oriposdataid"/>" class="normalradio"/>
            </td>       
            <td><custom:write name ="agreementsummary" property="year" nbsp="true"/></td>
            <td><custom:write name ="agreementsummary" property="month" nbsp="true"/></td>
            <td><custom:write name ="agreementsummary" property="area1name" nbsp="true"/></td>
            <td><custom:write name="agreementsummary" property="productcode"  nbsp="true"/></td>
            <td><custom:write name="agreementsummary" property="productname"  nbsp="true"/></td>
            <td><custom:write name="agreementsummary" property="listprice" nbsp="true"/></td>
            <td><custom:write name="agreementsummary" property="initialqty" nbsp="true"/></td>
            <td><custom:write name="agreementsummary" property="purchaseqty" nbsp="true"/></td>
            <td><custom:write name="agreementsummary" property="salesqty" nbsp="true"/></td>                     
            <td><custom:write name="agreementsummary" property="allqty" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="theoryqty" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="differenceqty" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="initialamount" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="purchaseamount" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="salesamount" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="allamount" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="theoryamount" nbsp="true"/></td>
			<td><custom:write name="agreementsummary" property="differenceamount" nbsp="true"/></td>	
			<td><custom:write name="agreementsummary" property="cnsales" nbsp="true"/></td>																	
          </tr>
          </logic:iterate> 
        <%
            String history=(String)pageContext.getAttribute("history");
        %> 
        <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top" ></td>
        </tr>
        <tr>
        
          <td class="td_center">
          	<a onclick="exportExcel();"><custom:button type="1" label="L_Execcd" imgsrc="delete.gif" border="0" style="width:60"/></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>

</table>
 </form>
</body>
</html>
